<%@ page import="top.lbqaq.pojo.Material" %>
<%@ page import="java.util.List" %>
<%@ page import="top.lbqaq.domain.PageBean" %><%--
  Created by IntelliJ IDEA.
  User: 12197
  Date: 2021/11/21
  Time: 13:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/jsp/common/head.jsp" %>
<div class="card-header d-flex justify-content-between">
    <div class="header-title">
        <h4 class="card-title">
            材料维护
        </h4>
    </div>
    <th scope="col"> <a href="/jsp/minsert.jsp" class="btn btn-primary btn-sm">新增</a></th>
</div>
  <p style="color: red;">${message}</p>
<div class="card-body">
    <div class="row">
        <div class="col-6">
            <form action="${pageContext.request.contextPath}/material?methodd=select" method="post">
                <div class="form-group">
                    <label>查询条件</label>
                    <select class="form-control form-control-sm mb-3" name="method">
                        <option value="selectAll" <c:if test="${'selectAll'.equals(materialList.way)}">selected </c:if> >查询全部</option>
                        <option value="selcetByCategory" <c:if test="${'selcetByCategory'.equals(materialList.way)}">selected</c:if>>按类别查询</option>
                        <option value="selectByName" <c:if test="${'selectByName'.equals(materialList.way)}">selected</c:if>>按名称查询</option>
                    </select>
                </div>
                <div class="form-group input-group-sm">
                    <input type="text" class="form-control" value="${materialList.name}" placeholder="填写条件" name="mingcheng"/>
                </div>
                <input type="submit" class="btn btn-primary btn-sm" value="提交"/>
            </form>
        </div>
    </div>


    <table class="table" style="text-align:center;">
        <thead>
        <tr class="ligth">
            <th scope="col">材料类别</th>
            <th scope="col">材料名称</th>
            <th scope="col">单位</th>
            <th scope="col">单价</th>
            <th scope="col">金额</th>
            <th scope="col">使用</th>
            <th scope="col">备注</th>
            <th scope="col"></th>
            <th scope="col"></th>
        </tr>
        </thead>
        <tbody>
        <c:forEach var="material" items="${materialList.list}">
            <tr>
                <th scope="col">${material.materialCategory}</th>
                <th scope="col">${material.materialName}</th>
                <th scope="col">${material.materialUnit}</th>
                <th scope="col">${material.materialUnitPrice}</th>
                <th scope="col">${material.materialAmount}</th>
                <th scope="col">${material.materialUse}</th>
                <th scope="col">${material.materialRemark}</th>
                <th scope="col"><a href="/material?methodd=goupdate&name=${material.materialName}&method=${materialList.name}&mthodd=${materialList.way}" class="btn btn-primary btn-sm">修改</a></th>
                <th scope="col"> <a href="/material?methodd=delete&name=${material.materialName}&method=${materialList.name}&mthodd=${materialList.way}"  class="btn btn-primary btn-sm">删除</a></th>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <c:if test="${materialList.totalCount!=0}">
        <div>
            <nav aria-label="Page navigation">
                <ul  class="col-6 pagination justify-content-end">
                    <c:if test="${materialList.currentPage==1}">
                        <li class="page-item">
                            <a class="page-link" href="${pageContext.request.contextPath}/material?methodd=select&&method=${materialList.way}&&currentPage=1&&mingcheng=${materialList.name}"
                               aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                    </c:if>

                    <c:if test="${materialList.currentPage!=1}">
                        <li class="page-item">
                            <a  class="page-link" href="${pageContext.request.contextPath}/material?methodd=select&&method=${materialList.way}&&currentPage=${materialList.currentPage-1}&&mingcheng=${materialList.name}"
                                aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                    </c:if>

                    <c:forEach begin="1" end="${materialList.totalPage}" var="i">
                        <li class="page-item">
                            <a class="page-link" href="${pageContext.request.contextPath}/material?methodd=select&&method=${materialList.way}&&mingcheng=${materialList.name}&&currentPage=${i}">${i}</a>
                        </li>
                    </c:forEach>

                    <c:if test="${materialList.currentPage==materialList.totalPage}">
                        <li class="page-item">
                            <a  class="page-link" href="${pageContext.request.contextPath}/material?methodd=select&&method=${materialList.way}&&currentPage=${materialList.totalPage}&&mingcheng=${materialList.name}"
                                aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </c:if>

                    <c:if test="${materialList.currentPage!=materialList.totalPage}">
                        <li class="page-item">
                            <a class="page-link" href="${pageContext.request.contextPath}/material?methodd=select&&method=${materialList.way}&&currentPage=${materialList.currentPage+1}&&mingcheng=${materialList.name}"
                               aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </c:if>

                    <div class="col-8">
                        当前为第${materialList.currentPage}/${materialList.totalPage}页，共${materialList.totalCount}条数据
                    </div>
                </ul>
            </nav>
        </div>
    </c:if>
</div>
<%@include file="/jsp/common/footer.jsp" %>
